# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=py3-libmdbx
pkgver=0.10.2
pkgrel=7
pkgdesc="Python bindings for libmdbx"
url="https://gitlab.com/thermi/py3-libmdbx/"
# ppc64le: test case segfaults
# loongarch64: tests fail
arch="noarch !ppc64le !loongarch64"
license="OLDAP-2.8"
depends="libmdbx"
makedepends="py3-setuptools py3-gpep517"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="py3-libmdbx-$pkgver.tar.gz::https://gitlab.com/Thermi/py3-libmdbx/-/archive/v$pkgver/py3-libmdbx-v$pkgver.tar.gz"

builddir="$srcdir/$pkgname-v$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	case "$CARCH" in
	riscv64)
		export PYTEST_ADDOPTS="$PYTEST_ADDOPTS
			--deselect libmdbx/tests/mdbx_test.py::TestMdbx::test_db_iter
			--deselect libmdbx/tests/mdbx_test.py::TestMdbx::test_db_readitem_writeitem
			--deselect libmdbx/tests/mdbx_test.py::TestMdbx::test_env
			--deselect libmdbx/tests/mdbx_test.py::TestMdbx::test_multi_write
			--deselect libmdbx/tests/mdbx_test.py::TestMdbx::test_replace
			--deselect libmdbx/tests/mdbx_test.py::TestMdbx::test_success_close_written_map
			--deselect libmdbx/tests/mdbx_test.py::TestMdbx::test_write
			"
		;;
	esac
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	gpep517 install-wheel --destdir .testenv --prefix '' .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	gpep517 install-wheel --destdir "$pkgdir" \
		.dist/*.whl
}

sha512sums="
3014aa59b7b00c53442b9d2ad2a4ca55f61381c754ea8df1d38d6e26b5ab9109564026efc533a13f4d15fe7a45dbe507a75928a6b47932c89fe7a1d977dc38c4  py3-libmdbx-0.10.2.tar.gz
"
